pp108 : Working with Javascript Message Bundles

Working with Javascript Message Bundles

A JavaScript Message Bundle is a collection of messages which are available for referencing from any JavaScript file. The JavaScript Message Bundles contain both the message texts and their translations. It provides a single central location to manage the messages and message translations of a JavaScript file.

  1. Select a starting point and click (JavaScript Bundle) to open the JavaScript Bundle editor. The JavaScript Bundle editor appears.
  2. Click (Add) on the toolbar. An editable row is added to the JavaScript Bundle editor.
  3. Make the appropriate modifications.
    • Enter the message under the Text column
    • Enter a unique identifier for the message in the Identifier column.
  4. Click (Save). The JavaScript Message Bundle is created and visible in Workspace Documents either in the Explorer or My Recent Documents view.
  5. Right-click the JavaScript Message Bundle and select Translate from the context-menu. The Translation Editor appears.
  6. Specify the translations of the messages in the appropriate target languages and click (Save). For information, see Translating Validation Messages.
  7. Right-click the JavaScript Message Bundle in the Workspace Documents and select Publish from the context-menu. This creates a MLM file for the JavaScript Message Bundle.

The JavaScript Message Bundle is ready for use in any JavaScript file.

You can use the APIs provided in the MessageBundle and Localization libraries to reference the JavaScript Message Bundle. Use the static API MessageBundle.get(path) to retrieve the localization object of a JavaScript Message Bundle, and use the get(textIdentifier) API to retrieve the TranslatableText object. For more information, see Localization and MessageBundle.

Related tasks

Translating Text to a Target Language
Reconstructing Missing Translations

Related reference

Accessing XForms and Translations using URLs